package hadoop.ch06.v17124080238;

import hadoop.ch06.v17124080238.HBaseDemo63;

import java.io.IOException;

public class App {

    static String tableName = "emp30";    //操作表名
    static String [] families = {"member_id", "info", "address"};  //列簇

    public static void main(String[] args) {
        useApi();
    }

    //采用API方法
    private static void useApi() {
        //所要插入的数据
        String rowkey = "Rain";
        int id = 31;
        int age = 28;
        String birthday = "1990-05-01";
        String industry = "architect";
        String city = "ShenZhen";
        String country = "China";
        try {
            //创建表
            HBaseDemo63.createTable(tableName, families);
            //插入数据
            System.out.println("插入数据    Rain, 31, 28, 1990-05-01, architect, ShenZhen, China");
            HBaseDemo63.insert(tableName, rowkey, families[0],"id", String.valueOf(id));
            HBaseDemo63.insert(tableName, rowkey, families[1],"age", String.valueOf(age));
            HBaseDemo63.insert(tableName, rowkey, families[1],"birthday", birthday);
            HBaseDemo63.insert(tableName, rowkey, families[1],"industry", industry);
            HBaseDemo63.insert(tableName, rowkey, families[2],"city", city);
            HBaseDemo63.insert(tableName, rowkey, families[2],"country", country);
            //获取一个数据项
            System.out.println("查询一个数据项：Rain info:age");
            HBaseDemo63.get(tableName,rowkey,"info","age");
            //扫描表
            System.out.println("扫描整个表");
            HBaseDemo63.scan(tableName);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
